/**
 * Created by jiangzhenzhen on 2016/5/5.
 */
/**
 * Created by jiangzhenzhen on 2016/5/3.
 */
$(document).ready(function() {

    $('#example').dataTable({
        "ajax": "data/arrays.txt",
        "dom": "<'row'<'col-xs-2'l><'#mytool.col-xs-10'><'col-xs-6'f>r>" +
        "t" +
        "<'row'<'col-xs-6'i><'col-xs-6'p>>",
        "columns": [
            //给第一列指定宽度为表格整个宽度的20%
            null,
            null,
            null,
            { "width": "20%" },
            { "width": "20%" },
            null
        ],

        searching: false,
        "bSort": false,
        "bAutoWidth":true,
        "lengthMenu": [5],
        "stripeClasses": [ 'strip1', 'strip2', 'strip3' ],
        "createdRow": function ( row, data, index ) {

            $('td', row).eq(0).addClass('border_left');
            $('td', row).eq(5).addClass('border_right');

        },
        "oLanguage": {//插件的汉化
            "sLengthMenu": "每页显示 _MENU_ 条记录",
            "sZeroRecords": "抱歉， 没有找到",
            "sInfo": "当前显示 _START_ 到 _END_条 ,共 _TOTAL_ 条记录",
            "sInfoEmpty": "没有数据",
            "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上一页",
                "sNext": "下一页",
                "sLast": "末页"
            },
            "sZeroRecords": "没有检索到数据",
            "sProcessing": "<img src='' />",
            "sSearch": "搜索"
        },
        "pagingType":   "full_numbers",
        "columnDefs": [ {
            "targets": -1,
            "data": null,
            "defaultContent": "<a href='#' class="+"check"+" target='_blank'>查看测量记录</a>"
        },
            {
                targets: 4,
                render: function(data, type, row, meta) {
                    return '<div class="state">异常</div><a type="button"  href="#" class="update">' +
                        'KB值修改</a><span class="get">已取</span>';

                },
            }
        ],

        "initComplete": function() {
            $("#mytool").append('<button id="delete_butt" type="button" class="btn btn-outline btn-success" style="float:right;margin-right:10px;background: #35c990;border:none;">删除</button>');

            $("#mytool").append('<button id="update_butt" type="button" class="btn btn-outline btn-success" style="float:right;;margin-right:10px;background: #35c990;border:none;">修改</button>');

            $("#mytool").append('<button id="add_butt" type="button" class="btn btn-outline btn-success" style="float:right;;margin-right:10px;background: #35c990;border:none;">新增</button>');

            $('#add_butt').on('click',ToAdd);
        }
    } );

    //增加
    function ToAdd(){
        window.parent.showModelIframe("http://localhost:8080/medicalcloud/src/main/webapp/newframe/frames/editorQuality/add.html","添加医院",800,400);
    }



} );